<template>
  <div class="station-auth-container">
    <div class="error-content">
      <div class="station-scene">
        <div class="platform">
          <div class="platform-edge"></div>
          <div class="warning-line"></div>
        </div>
        <div class="gate">
          <div class="gate-frame">
            <div class="gate-door left"></div>
            <div class="gate-door right"></div>
            <div class="gate-indicators">
              <div class="indicator red"></div>
              <div class="indicator red"></div>
            </div>
            <div class="gate-sign">
              <div class="access-denied">访问受限</div>
              <div class="auth-required">需要授权</div>
            </div>
          </div>
          <div class="id-scanner">
            <div class="scanner-screen">
              <div class="scan-line"></div>
              <div class="auth-error">验证失败</div>
            </div>
            <div class="scanner-light"></div>
          </div>
        </div>
        <div class="passenger">
          <div class="head"></div>
          <div class="body"></div>
          <div class="legs">
            <div class="leg"></div>
            <div class="leg"></div>
          </div>
          <div class="arms">
            <div class="arm left"></div>
            <div class="arm right"></div>
          </div>
          <div class="id-card"></div>
        </div>
      </div>

      <div class="error-message">
        <div class="error-code">401</div>
        <div class="error-title">无权限访问</div>
        <div class="error-desc">
          很抱歉，您没有访问该页面的权限。
          <br>请确认您的账号权限或联系系统管理员。
        </div>
        <div class="actions">
          <router-link to="/" class="home-button">
            <span class="icon">
              <i class="el-icon-back"></i>
            </span>
            <span>返回首页</span>
          </router-link>
          <button class="login-button" @click="goToLogin">
            <span class="icon">
              <i class="el-icon-key"></i>
            </span>
            <span>重新登录</span>
          </button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Page401',
  methods: {
    goToLogin() {
      this.$router.push('/login');
    }
  }
}
</script>

<style lang="scss" scoped>
.station-auth-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100vh;
  background: linear-gradient(180deg, #333333 0%, #1a1a1a 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  font-family: "Helvetica Neue", Arial, sans-serif;
  color: #f0f0f0;
  z-index: 2000;
}

.error-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90%;
  max-width: 980px;
}

.station-scene {
  width: 100%;
  height: 300px;
  position: relative;
  margin-bottom: 40px;
  perspective: 800px;
}

.platform {
  width: 100%;
  height: 60px;
  background-color: #555;
  position: absolute;
  bottom: 0;

  .platform-edge {
    height: 15px;
    width: 100%;
    background-color: #444;
    position: absolute;
    top: 0;
  }

  .warning-line {
    height: 8px;
    width: 100%;
    background: repeating-linear-gradient(
      45deg,
      #f8d568,
      #f8d568 10px,
      #333 10px,
      #333 20px
    );
    position: absolute;
    top: 16px;
  }
}

.gate {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  height: 180px;
  width: 160px;

  .gate-frame {
    height: 100%;
    width: 100%;
    border: 8px solid #444;
    border-bottom: none;
    background-color: rgba(50, 50, 50, 0.4);
    position: relative;
    overflow: hidden;

    .gate-door {
      position: absolute;
      width: 50%;
      height: 100%;
      background-color: rgba(70, 70, 70, 0.9);
      backdrop-filter: blur(10px);
      border: 2px solid #555;
      top: 0;

      &.left {
        left: 0;
        transform-origin: left;
        animation: doorBlock 3s infinite;
      }

      &.right {
        right: 0;
        transform-origin: right;
        animation: doorBlock 3s infinite;
      }
    }

    .gate-indicators {
      position: absolute;
      top: 20px;
      width: 100%;
      display: flex;
      justify-content: center;
      gap: 40px;
      z-index: 2;

      .indicator {
        width: 15px;
        height: 15px;
        border-radius: 50%;
        background-color: #B0332A;
        box-shadow: 0 0 10px rgba(255, 0, 0, 0.7);
        animation: blinkLight 1s infinite;

        &:nth-child(2) {
          animation-delay: 0.5s;
        }
      }
    }

    .gate-sign {
      position: absolute;
      bottom: 30px;
      left: 0;
      width: 100%;
      text-align: center;
      color: #fff;
      z-index: 2;

      .access-denied {
        font-size: 18px;
        font-weight: 700;
        color: #B0332A;
        margin-bottom: 8px;
        text-shadow: 0 0 8px rgba(255, 0, 0, 0.5);
      }

      .auth-required {
        font-size: 14px;
        color: #ddd;
      }
    }
  }

  .id-scanner {
    position: absolute;
    right: -50px;
    top: 50%;
    transform: translateY(-50%);
    height: 80px;
    width: 40px;
    background-color: #333;
    border-radius: 5px;
    border: 2px solid #444;

    .scanner-screen {
      width: 80%;
      height: 40px;
      background-color: #222;
      margin: 10px auto;
      border-radius: 3px;
      position: relative;
      overflow: hidden;

      .scan-line {
        position: absolute;
        width: 100%;
        height: 2px;
        background-color: #B0332A;
        top: 0;
        animation: scanMove 2s infinite;
      }

      .auth-error {
        position: absolute;
        bottom: 5px;
        left: 0;
        width: 100%;
        text-align: center;
        font-size: 8px;
        color: #B0332A;
        animation: blinkText 1s infinite;
      }
    }

    .scanner-light {
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background-color: #B0332A;
      margin: 5px auto;
      animation: blinkLight 1s infinite;
    }
  }
}

.passenger {
  position: absolute;
  bottom: 60px;
  left: 30%;
  height: 150px;
  width: 50px;
  animation: personMove 6s infinite;

  .head {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: #666;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
  }

  .body {
    width: 40px;
    height: 60px;
    background-color: #777;
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 10px 10px 0 0;
  }

  .legs {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 5px;

    .leg {
      width: 12px;
      height: 60px;
      background-color: #555;
      animation: legMove 1s infinite alternate;

      &:first-child {
        animation-delay: 0.5s;
      }
    }
  }

  .arms {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;

    .arm {
      position: absolute;
      width: 10px;
      height: 50px;
      background-color: #777;

      &.left {
        left: 0;
        transform-origin: top;
        transform: rotate(30deg);
      }

      &.right {
        right: 0;
        transform-origin: top;
        transform: rotate(-20deg);
      }
    }
  }

  .id-card {
    position: absolute;
    width: 20px;
    height: 15px;
    background-color: #ddd;
    top: 70px;
    right: 5px;
    transform: rotate(-20deg);
    animation: cardBlink 2s infinite;
  }
}

.error-message {
  text-align: center;
  max-width: 600px;

  .error-code {
    font-size: 120px;
    font-weight: 700;
    color: #CCCCCC;
    line-height: 1;
    text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.2);
    margin-bottom: 10px;
    opacity: 0;
    animation: fadeIn 0.8s 0.5s forwards;
  }

  .error-title {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #D0D0D0;
    opacity: 0;
    animation: fadeIn 0.8s 0.8s forwards;
  }

  .error-desc {
    font-size: 18px;
    line-height: 1.6;
    color: #A0A0A0;
    margin-bottom: 30px;
    opacity: 0;
    animation: fadeIn 0.8s 1.1s forwards;
  }

  .actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    opacity: 0;
    animation: fadeIn 0.8s 1.4s forwards;

    .home-button, .login-button {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 12px 20px;
      border-radius: 30px;
      font-size: 16px;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.3s ease;
      border: none;
      outline: none;

      .icon {
        display: flex;
        align-items: center;
        justify-content: center;
      }
    }

    .home-button {
      background-color: #3498db;
      color: white;
      box-shadow: 0 4px 6px rgba(52, 152, 219, 0.3);

      &:hover {
        background-color: #2980b9;
        transform: translateY(-2px);
      }
    }

    .login-button {
      background-color: #B0332A;
      color: white;
      box-shadow: 0 4px 6px rgba(176, 51, 42, 0.3);

      &:hover {
        background-color: #8E2922;
        transform: translateY(-2px);
      }
    }
  }
}

@keyframes doorBlock {
  0%, 10%, 90%, 100% {
    transform: translateX(0);
  }
  20%, 80% {
    transform: translateX(0);
  }
  30%, 40%, 50%, 60%, 70% {
    transform: translateX(0) scaleX(0.98);
  }
}

@keyframes blinkLight {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.7);
  }
  50% {
    opacity: 0.5;
    box-shadow: 0 0 5px rgba(255, 0, 0, 0.4);
  }
}

@keyframes scanMove {
  0% {
    top: 0;
    opacity: 0.8;
  }
  100% {
    top: 100%;
    opacity: 0.2;
  }
}

@keyframes personMove {
  0%, 100% {
    transform: translateX(0);
  }
  40% {
    transform: translateX(160px);
  }
  45% {
    transform: translateX(160px) translateY(-5px);
  }
  50% {
    transform: translateX(160px);
  }
  55% {
    transform: translateX(130px);
  }
}

@keyframes legMove {
  0% {
    height: 60px;
  }
  100% {
    height: 55px;
  }
}

@keyframes cardBlink {
  0%, 100% {
    background-color: #ddd;
  }
  50% {
    background-color: #B0332A;
  }
}

@keyframes blinkText {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 768px) {
  .error-content {
    width: 95%;
  }

  .station-scene {
    height: 250px;
  }

  .gate {
    transform: translateX(-50%) scale(0.8);
  }

  .passenger {
    left: 20%;
    transform: scale(0.9);
  }

  .error-message {
    .error-code {
      font-size: 80px;
    }

    .error-title {
      font-size: 26px;
    }

    .error-desc {
      font-size: 16px;
    }

    .actions {
      flex-direction: column;
      gap: 12px;

      .home-button, .login-button {
        width: 100%;
        justify-content: center;
      }
    }
  }
}
</style>
